package com.buka.utils;

import com.buka.http.HttpCode;

/**
 * 结果集类
 */
public class ResponseJson {

    private int code;
    private String msg;
    private Object data;

    public ResponseJson() {
    }

    public ResponseJson(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static ResponseJson getInstance(int code, String msg, Object data) {
        return new ResponseJson(code, msg, data);
    }

    public static ResponseJson getInstance(HttpCode httpCode, Object data) {
        return new ResponseJson(httpCode.getCode(), httpCode.getMsg(), data);
    }

    public static ResponseJson getOK() {
        return getInstance(HttpCode.SUCCESS, null);
    }

    public static ResponseJson getOK(Object data) {
        return getInstance(HttpCode.SUCCESS, data);
    }

    public static ResponseJson getOK(String msg) {
        return getInstance(HttpCode.SUCCESS.getCode(), msg, null);
    }

    public static ResponseJson getError() {
        return getInstance(HttpCode.ERROR, null);
    }

    public static ResponseJson getError(String msg) {
        return getInstance(HttpCode.ERROR.getCode(), msg, null);
    }
}

